function getTeamName(platform_code, type_code, league_code, team_code, team_kind) {
    $("#rate_team_" + team_kind + "_name_loading_zone").show();
    $("#rate_team_" + team_kind + "_name_data_zone").hide();
    $("#rate_team_" + team_kind + "_name_error_zone").hide();
    var token = getCookie('csrftoken');
    $.ajax({
        url: '/football/get_team_name/',
        type: 'POST',
        headers:{'X-CSRFToken': token},
        data: {'platform_code': platform_code, 'type_code': type_code, 'league_code': league_code, 'team_code': team_code},
        success: function(data) {
            let jsonData = $.parseJSON(data);
            console.log(jsonData);
            $("#rate_team_" + team_kind + "_name_data_zone").html(jsonData);
            $("#rate_team_" + team_kind + "_name_loading_zone").hide();
            $("#rate_team_" + team_kind + "_name_error_zone").hide();
            $("#rate_team_" + team_kind + "_name_data_zone").show();
        },
        error: function() {
            $("#rate_team_" + team_kind + "_name_loading_zone").hide();
            $("#rate_team_" + team_kind + "_name_data_zone").hide();
            $("#rate_team_" + team_kind + "_name_error_zone").show();
        }
    });
}

function getLeagueName(platform_code, type_code, league_code) {
    $("#rate_league_name_loading_zone").show();
    $("#rate_league_name_data_zone").hide();
    $("#rate_league_name_error_zone").hide();
    var token = getCookie('csrftoken');
    $.ajax({
        url: '/football/get_league_name/',
        type: 'POST',
        headers:{'X-CSRFToken': token},
        data: {'platform_code': platform_code, 'type_code': type_code, 'league_code': league_code},
        success: function(data) {
            let jsonData = $.parseJSON(data);
            console.log(jsonData);
            $("#rate_league_name_data_zone").html(jsonData);
            $("#rate_league_name_loading_zone").hide();
            $("#rate_league_name_error_zone").hide();
            $("#rate_league_name_data_zone").show();
        },
        error: function() {
            $("#rate_league_name_loading_zone").hide();
            $("#rate_league_name_data_zone").hide();
            $("#rate_league_name_error_zone").show();
        }
    });
}

function goToOtherPage(path) {
    window.location.href = path;
}

function navigateToDatePage() {
    goToOtherPage('./choose_date.html');
}

function getCookie(name) {
    var matches = document.cookie.match(new RegExp(
        "(?:^|; )" + name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$&') + "=([^;]*)"
    ));
    return matches ? decodeURIComponent(matches[1]) : undefined;
}